Skip to content

fix: add iteration limit to SPV fee calculation loop#620

Merged
lklimek merged 1 commit intodashpay:v1.0-devfrom
thepastaclaw:fix/spv-fee-loop-limit
Feb 26, 2026
Merged

fix: add iteration limit to SPV fee calculation loop#620
lklimek merged 1 commit intodashpay:v1.0-devfrom
thepastaclaw:fix/spv-fee-loop-limit

Conversation

@thepastaclaw
Copy link
Collaborator

@thepastaclaw thepastaclaw commented Feb 22, 2026

Replace unbounded loop with a capped for loop (max 50 iterations) in the SPV fee calculation to prevent potential infinite loops.

Problem

The fee estimation loop in build_transaction_for_spv_wallet uses an unbounded loop that adjusts a scale factor to find a valid transaction. If the scale factor converges without meeting either exit condition (successful build or InsufficientFunds with no progress), the loop runs forever.

Fix

Cap the loop at 50 iterations and return a clear error if no valid transaction is found within that budget. 50 iterations is generous — in practice, convergence happens within 2-3 iterations.

Cherry-picked from ralph/improvements (commit 557acb2).

Validation

What was tested:

  • cargo clippy --all-features --all-targets -- -D warnings — lint check
  • cargo test --all-features --workspace — full workspace test suite

Results:

  • All local commands passed
  • Clippy CI check — pass (5m27s)
  • Test Suite CI check — pass (7m1s)

Environment: Local macOS arm64; GitHub Actions CI (ubuntu-latest)

Replace unbounded loop with a capped for loop (max 50 iterations)
in the SPV fee calculation to prevent potential infinite loops when
the scale factor converges but never meets the exit condition.

Cherry-picked from ralph/improvements (commit 557acb2).
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

Warning

Rate limit exceeded

@lklimek has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 513cc87 and 9f4f7a4.

📒 Files selected for processing (1)
  • src/backend_task/core/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

@thepastaclaw thepastaclaw marked this pull request as draft February 25, 2026 08:22
@lklimek lklimek marked this pull request as ready for review February 26, 2026 13:03
@lklimek lklimek merged commit 0a78539 into dashpay:v1.0-dev Feb 26, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants